function [ Y ] = DAGclassify( X, HP )
    N = size(X,1);
    C = 48;
    Table = zeros(C*C, 62);
    Index = zeros(C*C, 1);
    k = 0;
    for a = (1:C)
        for b = (1:C)
            k = k+1;
            Index(a,b) = k;
            Table(k,:) = squeeze(HP(a,b,:));
        end
    end

    list = (1:C)';

    a = ones(N,1);
    b = ones(N,1)*C;
    for i = (2:length(list))
        v = [X ones(N,1)] .* Table( Index( sub2ind(size(Index),list(a),list(b)) ), : ) * ones(62,1);
        a( v < 0 ) = a( v < 0 ) + 1;
        b( v >= 0 ) = b( v >= 0 ) - 1;
    end
    Y = list(a);
end